package cn.tannn.cat.file.server.controller.manage.dto;

import cn.tannn.cat.file.server.entity.Dict;
import cn.tannn.cat.file.server.enums.DictStatus;
import cn.tannn.cat.file.server.enums.DictType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * 新增字典
 *
 * @author <a href="https://tannn.cn/">tan</a>
 * @date 2024/3/8 9:34
 */
@Schema(description = "新增字典")
@ToString
@Getter
@Setter
public class DictAppend {
    /**
     * 字典标签
     */
    @Schema(description = "字典标签")
    @NotBlank
    private String label;

    /**
     * 字典键值
     */
    @Schema(description = "字典键值")
    @NotBlank
    private String value;

    /**
     * 字典类型
     * @see DictType
     */
    @Schema(description = "字典类型")
    private DictType dictType;


    /**
     * 备注
     */
    @Schema(description = "备注")
    private String remark;

    public Dict toDict(){
        Dict dict = new Dict();
        dict.setLabel(this.label);
        dict.setValue(this.value);
        dict.setDictType(this.dictType);
        dict.setStatus(DictStatus.ENABLE);
        dict.setSort(999);
        dict.setRemark(this.remark);
        return dict;
    }
}
